package cn.piggy.config;

import cn.piggy.util.ObjectMapperUtil;

import java.io.IOException;
import java.util.Properties;

public class ConfigParam {

    private ConfigParam(){}

    private static volatile ConfigParam configParam;
    public static ConfigParam getConfigParam() throws IOException {
        if(configParam==null){
            synchronized (ObjectMapperUtil.class){
                if(configParam==null){
                    configParam = new ConfigParam();
                    Properties prop = new Properties();
                    prop.load(ConfigParam.class.getClassLoader().getResourceAsStream("application.properties"));
                    configParam.setApiHost(prop.getProperty("baidu.config.answer.apiHost"));
                    configParam.setApiKey(prop.getProperty("baidu.config.apiKey"));
                    configParam.setAppId(prop.getProperty("baidu.config.appId"));
                    configParam.setAuthHost(prop.getProperty("baidu.config.authHost"));
                    configParam.setClientId(prop.getProperty("baidu.config.clientId"));
                    configParam.setClientSecret(prop.getProperty("baidu.config.clientSecret"));
                    configParam.setQueryHost(prop.getProperty("baidu.config.tran.queryHost"));
                    configParam.setCreateHost(prop.getProperty("baidu.config.tran.createHost"));
                    configParam.setSecretKey(prop.getProperty("baidu.config.secretKey"));
                }
            }
        }
        return configParam;
    }

    private String apiHost;
    private String createHost;
    private String queryHost;
    private String authHost;
    private String clientId;
    private String clientSecret;
    private String appId;
    private String apiKey;
    private String secretKey;

    public String getApiHost() {
        return apiHost;
    }

    public void setApiHost(String apiHost) {
        this.apiHost = apiHost;
    }

    public String getCreateHost() {
        return createHost;
    }

    public void setCreateHost(String createHost) {
        this.createHost = createHost;
    }

    public String getQueryHost() {
        return queryHost;
    }

    public void setQueryHost(String queryHost) {
        this.queryHost = queryHost;
    }

    public String getAuthHost() {
        return authHost;
    }

    public void setAuthHost(String authHost) {
        this.authHost = authHost;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getClientSecret() {
        return clientSecret;
    }

    public void setClientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getApiKey() {
        return apiKey;
    }

    public void setApiKey(String apiKey) {
        this.apiKey = apiKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }
}
